<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>微信群发</title>
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="../css/aui.2.0.css">
    <link rel="stylesheet" href="../css/alert.css">
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/common1.css">
    <link rel="stylesheet" href="../css/reset.css">
    <link rel="stylesheet" href="../css/wxmass.css">
</head>
<body>
<section>
    <header class="aui-bar aui-bar-nav" id="aui-header">
        <div class="aui-col-xs-3 my-col-xs-3">
            <i class="aui-iconfont aui-icon-left"></i>
        </div>
        <div class="aui-title my-aui-title">微信群发</div>
    </header>
    <section class="wxmass-box">
        <div class="wxmass-box-img">
            <img src="../images/piliang.jpg" alt="">
        </div>
        <div class="wxmass-box-list">
            <ul id="shop-batch">
                <script type="text/x-handlebars-template" id="shop-batch-template">
                    {{#each this}}
                    <li class="wxmass-list-li" data-id="{{id}}">
                        <!--第几波商品-->
                        <div class="wxmass-list-len">
                            <!--购物袋-->
                            <div class="wxmass-list-dd"></div>
                            <div class="wxmass-list-sp">
                                <p>{{name}}</p>
                                <span>{{content}}</span>
                            </div>
                        </div>
                        <!--发送-->
                        <div class="wxmass-list-send"><span>批量发送</span></div>
                    </li>
                    {{/each}}
                </script>

                <!--<li class="wxmass-list-li">
                    &lt;!&ndash;第几波商品&ndash;&gt;
                    <div class="wxmass-list-len">
                        &lt;!&ndash;购物袋&ndash;&gt;
                        <div class="wxmass-list-dd"></div>
                        <div class="wxmass-list-sp">
                            <p>第一波商品</p>
                            <span>第10-18个精选商品</span>
                        </div>
                    </div>
                    &lt;!&ndash;发送&ndash;&gt;
                    <div class="wxmass-list-send"><span>批量发送</span></div>
                </li>-->

            </ul>
            <div class="wxmass-list-xts"><span>小提示：批量发送时已经抢光的精选商品不会被发送</span></div>

        </div>


    </section>
    <section class="share-loading">
        <img src="../images/loading.gif" alt="">
    </section>
    <!--批量发送遮罩层-->
    <section class="wxmass-sends">
        <section class="wxmass-sends-item">
            <div class="wxmass-item-title">
                <span class="cancel">取消</span>
                <span>共9张</span>

            </div>
            <div class="wxmass-item-img">
                <img src="../images/banner1.png" alt="">
            </div>
            <ul class="wxmass-item-list">
                <li>
                    <div class="wxmass-item-list-img">
                        <img src="../images/sends1.png" alt="">
                    </div>
                    <span>发送给朋友</span>
                    <div class="aui-col-xs-3 wxmass-col-xs-3">
                        <i class="aui-iconfont aui-icon-right"></i>
                    </div>
                </li>
                <li>
                    <div class="wxmass-item-list-img">
                        <img src="../images/sends2.png" alt="">
                    </div>
                    <span>分享到朋友圈</span>
                    <div class="aui-col-xs-3 wxmass-col-xs-3">
                        <i class="aui-iconfont aui-icon-right"></i>
                    </div>
                </li>
                <li class="no-border">
                    <div class="wxmass-item-list-img">
                        <img src="../images/sends3.png" alt="">
                    </div>
                    <span>收藏</span>
                    <div class="aui-col-xs-3 wxmass-col-xs-3">
                        <i class="aui-iconfont aui-icon-right"></i>
                    </div>
                </li>
            </ul>
        </section>

    </section>
</section>
<script src="../js/jquery-3.0.0.min.js"></script>
<script src="../js/handlebars-v4.0.10.js"></script>
<script src="../js/config.js"></script>
<script src="../js/common.js"></script>
<script src="../js/function.js"></script>
<script src="../js/alert.js"></script>
<script>

    var batchTpl=$('#shop-batch-template').html();
    var batchCmp=Handlebars.compile(batchTpl);


    $.ajax({
        url:C.marketInterface.batchShare,
        type:'get',
        dataType:'json',
        data:{
            token:C.marketToken
        },
        success:function (response) {
            if (response.result=='success'){

                var data=response.data;
                $('#shop-batch').html(batchCmp(data));


                $('.wxmass-list-send').unbind().bind('click',function (event) {

                    getBatchShare(event,$(this));

                });


                $('.cancel').click(function () {
                    $('.wxmass-sends').toggle();
                });

            }else if (response.result=='login'){
            	dialog.tusiError('登录已过期请重新登录');

            }else {
            	dialog.tusiError(response.errorMsg);
            }
        },
        error:function () {
            //alert('服务器异常');
        }
    });

    function getBatchShare(event,that) {
        event.preventDefault();
        event.stopPropagation();
        var id=that.parent('.wxmass-list-li').data('id');
        var data={
            id:id,
            postType:'batchShare'
        };

        var ua = navigator.userAgent.toLowerCase();
        if (/iphone|ipad|ipod/.test(ua)) {

            iosBatchShare(data);
            event.stopPropagation();
        } else {
            //console.log(JSON.stringify(data));
            androidBatchShare(JSON.stringify(data));
            event.stopPropagation();
        }

    }


    //安卓拉取分享
    function androidBatchShare(param) {
        window.huifa.batchShare(param);
    }
    //iOS拉取分享
    function iosBatchShare(param) {
        window.webkit.messageHandlers.batchShare.postMessage(param);
    }

    /*function batchShare(event,that) {
        event.preventDefault();
        event.stopPropagation();
        var id=that.parent('.wxmass-list-li').data('id');


        $('.share-loading').show();
        //$('.wxmass-sends').toggle();

        $.ajax({
            url:C.marketInterface.weixinBatchSend,
            type:'get',
            dataType:'json',
            data:{
                token:C.marketToken,
                id:id
            },
            success:function (response) {
                if (response.result=='success'){

                    var data=response.data;
                    //var shareImg=$('.wxmass-sends').find('.wxmass-item-img').find('img').attr();

                    //console.log(shareImg);
                    console.log(data);
                    $('.share-loading').hide();
                    $('.wxmass-sends').toggle();

                }else if (response.result=='login'){
                    alert('请重新登录');

                }else {
                    alert(response.errorMsg);
                }
            },
            error:function () {
                alert('服务器异常');
            }
        })
    }*/





</script>

</body>
</html>